require(["config"],function(config){
	require(["jquery.ui","jquery", "zepto", "sw","common","cookie","jqzoom","pagescroll"],function(jqui,jq,zep,swiper,common,cookie,jqzoom,pagescroll){
		
/*
 	用ajax调用detail_r_intro.json文件，获得商品的详细信息,完成购物车列表
 * */
	//console.log(window.location.search.split("=")[1])

	jq.ajax({
		url : "./json/detail_r_intro.json" ,
		type : "GET"
	})
	.done(function(data){
		var str="";
		//从cookie中取出加入购物的商品的id，
		var goods_cart_list=jq.cookie("goodsid").split("");
		//console.log(goods_cart_list)
		data[0].goodsinfor.forEach(function(item,index){
			//判断id在购物车的商品显现
			if(common.has(goods_cart_list,item.id)){
				str += '<div class="cart_content"><div class="goods_check cart_con"><input type="checkbox" checked="checked"/></div><a class="goods_content01 cart_con" href=""><img src=' + item.goodsimg +' alt="" /></a><div class="goods_content02 cart_con"><p>' + item.goodsthead + '</p><p>' + item.describe + '</p><p class="backgoods">支持7天无理由退货</p></div><div class="goods_content03 cart_con"><p>颜色：' + item.color[0] +' </p><p>尺码：' + item.size[0] +'</p></div><div class="goods_content04 cart_con">' + item.price +'</div><div class="goods_content05 cart_con"><u class="cart_reduce">-</u><u id="cart_goodsnumber">1</u><u class="cart_add">+</u><p>库存<em class="cart_storenum">' + item.storenum +'</em>件</p></div><div class="goods_content06 cart_con">¥45.90</div><a href="#" class="goods_content07 cart_con">删除</a></div>';
				jq(".cart_item_list").html(str);
			}
					
		})
		
		
/*
 	购买数量加减
 * */
		jq(".cart_add").click(function(){
			if(Number(jq("#cart_goodsnumber").html())<Number(jq(".cart_storenum").html())){
				jq("#cart_goodsnumber").html(Number(jq("#cart_goodsnumber").html())+1);
			}
		})
		jq(".cart_reduce").click(function(){
			if(Number(jq("#cart_goodsnumber").html())>1){
				jq("#cart_goodsnumber").html(Number(jq("#cart_goodsnumber").html())-1);
			}
		})
	
		
		
	})
		



	})
})
